package tool.plot

import java.io.File

import implicits.Implicits._
import shared.Pojo._
import tool.Pojo._
import tool.Tool
import tool.plot.AllPlot.RPlotB

/**
 * Created by yz on 27/9/2020
 */
object Features extends FeaturesT with RPlotB {

  def producePlotConfigFile(data: AllPlotData, workspaceDir: File, extraData: ExtraDataData) = {
    Tool.dataCoverConfigFile(data, workspaceDir, configFileName, configJsonFileName)
  }

  override def getCommand(data: AllPlotData, extraData: ExtraDataData): String = {
    val (layout,font)=(data.layout,data.font)
    val fname = if(layout. feaf == "one") s" --feature_name ${layout.feafname}"  else ""
    s"""
       |python ${new File(Tool.pyPath, "plot_features.py").unixPath}  lefse_format.txt lefse_LDA.xls lefse_LDA.features.pdf --format pdf -f ${layout.feaf} ${fname} --width ${layout.width} --height ${layout.height} --top ${layout.featop} --bot ${layout.feabot} --title_font_size ${data.mainTitleFont} --class_font_size ${font.feacfs} --subcl_mean ${layout.feasmean} --subcl_median ${layout.feasmedian} --font_size ${data.yFont} --dpi 300 --class_angle ${layout.feaca}
       |convert  -density 300 lefse_LDA.features.pdf[0] lefse_LDA.features.png
       |""".stripMargin
  }

  override def defaultPlotArg(tmpPlotData: AllPlotData): AllPlotData = {
    val initData = AllPlotData()
    tmpPlotData.copy(
      mainTitle = "Cladogram",
      mainTitleFont = "14"
    )
  }

}

